﻿Public Class CommandList
    Public Function GetIcon(strCmd As String, Optional type As Integer = 0) As Bitmap
        Select Case strCmd
            Case "HELP"
                Return My.Resources.help
            Case "SETTING"
                Return My.Resources.setting
            Case "EXIT"
                Return My.Resources._exit
            Case "HALT"
                Return My.Resources.shutdown
            Case "REBOOT"
                Return My.Resources.reboot
            Case "HIBERNATE"
                Return My.Resources.hibernate
            Case "LOGOUT"
                Return My.Resources.logout
            Case "CONTROLPANEL"
                Return My.Resources.control
            Case "CMD"
                Return My.Resources.cmd
            Case "CALC"
                Return My.Resources.calc
            Case "NOTEPAD"
                Return My.Resources.notepad
            Case "MSPAINT"
                Return My.Resources.mspaint
            Case "EXPLORER"
                Return My.Resources.explorer
            Case "MAGNIFY"
                Return My.Resources.magnify
            Case "NARRATOR"
                Return My.Resources.Narrator
            Case "OSK"
                Return My.Resources.osk
            Case "QUICKASSIST"
                Return My.Resources.quickassist
            Case "CLEANMGR"
                Return My.Resources.cleanmgr
            Case "SERVICES"
                Return My.Resources.services
            Case "COMPMGMT"
                Return My.Resources.compmgmt
            Case "TASKSCHD"
                Return My.Resources.taskschd
            Case "EVENTVWR"
                Return My.Resources.eventvwr
            Case "DFRGUI"
                Return My.Resources.dfrgui
            Case "MSCONFIG"
                Return My.Resources.msconfig
            Case "MSINFO32"
                Return My.Resources.msinfo32
            Case "PERFMON"
                Return My.Resources.perfmon
            Case "REGEDIT"
                Return My.Resources.regedit
            Case "PERFMONRES"
                Return My.Resources.perfmonres
            Case "COMEXP"
                Return My.Resources.comexp
            Case "CHARMAP"
                Return My.Resources.charmap
            Case "PSR"
                Return My.Resources.psr
            Case "SNIPPINGTOOL"
                Return My.Resources.SnippingTool
            Case "MSTSC"
                Return My.Resources.mstsc
            Case "MDSCHED"
                Return My.Resources.MdSched
            Case "TASKMGR"
                Return My.Resources.taskmgr
            Case Else
                If type = 0 Then
                    Return My.Resources.execute
                ElseIf type = 1 Then
                    Return My.Resources.execute
                ElseIf type = 2 Then
                    Return My.Resources.internet
                ElseIf type = 3 Then
                    Return My.Resources.folder
                ElseIf type = 4 Then
                    Return My.Resources.execute
                ElseIf type = 5 Then
                    Return My.Resources.folder
                Else
                    Return My.Resources.execute
                End If
        End Select
    End Function

    Public Function RunCmd(strCmd As String) As Boolean
        Select Case strCmd
            Case "HELP"
                MsgBox(AppName + "是一个简洁轻量、容易使用的应用程序快速启动工具。" + vbCrLf + vbCrLf +
                       "快捷键：" + vbCrLf +
                       "Alt + Space（Shift + Space）    显示/隐藏搜索窗口" + vbCrLf + vbCrLf +
                       "项目主页：" + AppUrl, vbOKOnly + vbInformation, "帮助")
            Case "SETTING"
                FrmMain.MenuSetting_Click(Me, New EventArgs)
            Case "EXIT"
                FrmMain.MenuExit_Click(Me, New EventArgs)
            Case "HALT"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "shutdown",
                    .Arguments = "/s /t 0",
                    .WindowStyle = ProcessWindowStyle.Hidden
                }
                Process.Start(pInfo)
            Case "REBOOT"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "shutdown",
                    .Arguments = "/r /t 0",
                    .WindowStyle = ProcessWindowStyle.Hidden
                }
                Process.Start(pInfo)
            Case "HIBERNATE"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "shutdown",
                    .Arguments = "/h /t 0",
                    .WindowStyle = ProcessWindowStyle.Hidden
                }
                Process.Start(pInfo)
            Case "LOGOUT"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "shutdown",
                    .Arguments = "/l /t 0",
                    .WindowStyle = ProcessWindowStyle.Hidden
                }
                Process.Start(pInfo)
            Case "CONTROLPANEL"
                Process.Start("control")
            Case "CMD"
                Process.Start("cmd")
            Case "CALC"
                Process.Start("calc")
            Case "NOTEPAD"
                Process.Start("notepad")
            Case "MSPAINT"
                Process.Start("mspaint")
            Case "EXPLORER"
                Process.Start("explorer")
            Case "MAGNIFY"
                Process.Start("magnify")
            Case "NARRATOR"
                Process.Start("narrator")
            Case "OSK"
                Process.Start("osk")
            Case "QUICKASSIST"
                Process.Start("quickassist")
            Case "CLEANMGR"
                Process.Start("cleanmgr")
            Case "SERVICES"
                Process.Start("services.msc")
            Case "COMPMGMT"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "compmgmt.msc",
                    .Arguments = "/s"
                }
                Process.Start(pInfo)
            Case "TASKSCHD"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "taskschd.msc",
                    .Arguments = "/s"
                }
                Process.Start(pInfo)
            Case "EVENTVWR"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "eventvwr.msc",
                    .Arguments = "/s"
                }
                Process.Start(pInfo)
            Case "DFRGUI"
                Process.Start("dfrgui")
            Case "MSCONFIG"
                Process.Start("msconfig")
            Case "MSINFO32"
                Process.Start("msinfo32")
            Case "PERFMON"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "perfmon.msc",
                    .Arguments = "/s"
                }
                Process.Start(pInfo)
            Case "REGEDIT"
                Process.Start("regedit")
            Case "PERFMONRES"
                Dim pInfo As New ProcessStartInfo With {
                    .FileName = "perfmon",
                    .Arguments = "/res"
                }
                Process.Start(pInfo)
            Case "COMEXP"
                Process.Start("comexp.msc")
            Case "CHARMAP"
                Process.Start("charmap")
            Case "PSR"
                Process.Start("psr")
            Case "SNIPPINGTOOL"
                Process.Start("SnippingTool")
            Case "MSTSC"
                Process.Start("mstsc")
            Case "MDSCHED"
                Process.Start("MdSched")
            Case "TASKMGR"
                Process.Start("taskmgr")
            Case Else
                Return False
        End Select
        Return True
    End Function

    Public Function IsCommand(strCmd As String) As Boolean
        If strCmd = "HELP" Or
            strCmd = "SETTING" Or
            strCmd = "EXIT" Or
            strCmd = "HALT" Or
            strCmd = "REBOOT" Or
            strCmd = "HIBERNATE" Or
            strCmd = "LOGOUT" Or
            strCmd = "CONTROLPANEL" Or
            strCmd = "CMD" Or
            strCmd = "CALC" Or
            strCmd = "NOTEPAD" Or
            strCmd = "MSPAINT" Or
            strCmd = "EXPLORER" Or
            strCmd = "MAGNIFY" Or
            strCmd = "NARRATOR" Or
            strCmd = "OSK" Or
            strCmd = "QUICKASSIST" Or
            strCmd = "CLEANMGR" Or
            strCmd = "SERVICES" Or
            strCmd = "COMPMGMT" Or
            strCmd = "TASKSCHD" Or
            strCmd = "EVENTVWR" Or
            strCmd = "DFRGUI" Or
            strCmd = "MSCONFIG" Or
            strCmd = "MSINFO32" Or
            strCmd = "PERFMON" Or
            strCmd = "REGEDIT" Or
            strCmd = "PERFMONRES" Or
            strCmd = "COMEXP" Or
            strCmd = "CHARMAP" Or
            strCmd = "PSR" Or
            strCmd = "SNIPPINGTOOL" Or
            strCmd = "MSTSC" Or
            strCmd = "MDSCHED" Or
            strCmd = "TASKMGR" Then
            Return True
        Else
            Return False
        End If
    End Function
End Class
